﻿#define _CRT_SECURE_NO_WARNINGS 1

//编程初学者入门训练第103题
//BC105 矩阵相等判定
//https://www.nowcoder.com/practice/2f058b1e89ae43f7ab650c0fd0b71fa8?tpId=107&tqId=33386&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D2%26tpId%3D107%26type%3D107&difficulty=undefined&judgeStatus=undefined&tags=&title=

#include <stdio.h>

int main() {
    int n = 0, m = 0;
    scanf("%d %d", &n, &m);
    int arr[10][10] = { 0 };
    int arr1[10][10] = { 0 };

    //输入
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%d", &arr[i][j]);
        }
    }

    //比较两个数组
    int temp = 0;
    int flag = 0;//相等为0，不等为1
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%d", &temp);
            if (temp != arr[i][j])
                flag = 1;
        }

    }

    if (flag) {
        printf("No\n");
    }
    else {
        printf("Yes\n");
    }

    return 0;
}